<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
    <title>修改密码</title>
    <link rel="stylesheet" href="css/base.css" />
    <link rel="stylesheet" href="css/set.css" />
    <link rel="stylesheet" href="css/all.css" />
</head>
<body>
<div>
    <div class="heads">
        <span href="javascript:;" onclick="go()"><img src="img/zuojiantou.png" alt="" class="arrows"></span>
        <h1 class="titles">修改密码</h1>
    </div>
    <div class="middle">
        <form action="">
            <div class="resetUpwd">
                <input type="text" placeholder="请输入原始密码" class="resetUpwd-input" id="change-password"/>
            </div>
            <div class="resetUpwd">
                <input type="password" placeholder="请输入新密码" class="resetUpwd-input" id="change-newPassword"/>
            </div>
            <div class="resetUpwd">
                <input type="password" placeholder="请输入确认密码" class="resetUpwd-input" id="change-confirmNewPassword"/>
            </div>
            <!--<a type="button" class="submit" >
                <div class="submits">确定</div>
            </a>-->
            <div class="submit">
            	<button type="button" class="submits">
            		确定
	            </button>
            </div>
             
        </form>
    </div>
</div>
<script src="js/jquery.js"></script>
<script src="js/x_rem.js"></script>
<script src="js/secondLevel.js"></script>
<script src="js/all.js"></script>
<script>
	//
	(()=>{
		var Password = $("#change-password");
		var newPassword = $("#change-newPassword")
		
		var confirmNewPassword = $("#change-confirmNewPassword");
		
		
		
		$(".submits").click(()=>{
			if(!vali(Password, /^[a-zA-Z0-9_]{6}$/, "请输入正确的原始密码格式")){
					
			}else if(!vali(newPassword, /^[a-zA-Z0-9_]{6}$/ , "请输入正确的新密码格式")){
					
			}else if(confirmNewPassword.val() != newPassword.val()){
				popup("两次密码不一致");
			}else{
				$.ajax({
					type:"post",
					url:Url+"/user/updatePassword",
					xhrFields:{
						withCredentials: true
					},
					data:{
						"password": Password.val(),
						"newPassword":newPassword.val()
					},
					success:((data)=>{
						console.log(data);
						
						popup(data.message);
						if(data.success){
//							location.href = "home-page.html";
						}
					}),
					error:((error)=>{
						console.log(error);
					})
				})
			}
				
			
			
			
			
		})
		
		
		
		
		
	})()
	
	
	
</script>
</body>
</html>